<script>
    // apply的原理
    ; (function () {
        function mlapply(context,args) {
            context = context ? Object(context) : window;
            // this  表示fn
            // this() 不OK
            context.f = this;
            if(!args){
                return context.f();
            }
            let res = context.f(...args)
            delete context.f;
            return res;
        }
        Function.prototype.mlapply = mlapply;
    }())

    function fn(num1, num2) {
        console.log(this);
        return num1 + num2
    }
    let obj = { name: "码路" }
    // 1)改变fn中this的指向
    // 2)apply可以让函数调用
    // 3)返回函数调用的结果
    // let res = fn.apply(obj, [6, 8])
    let res = fn.mlapply(obj, [6, 8])
    console.log(res)
</script>